package com.lookwider.services.impl;

import com.lookwider.beans.JobCategory;
import com.lookwider.services.JobsService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.google.common.collect.Lists.newArrayList;

@Service
public class JobsServiceImpl implements JobsService {

    @Override
    public List<JobCategory> findAllMainCategories() {
        List<JobCategory> jobCategories = newArrayList();
        jobCategories.add( jobCategory( 0, "Eat", "blue" ) );
        jobCategories.add( jobCategory( 1, "Medicine", "pink") );
        jobCategories.add( jobCategory( 2, "Rest", "purple") );
        jobCategories.add( jobCategory( 3, "Peace", "greenLight" ) );
        jobCategories.add( jobCategory( 4, "CTO", "yellow" ) );
        jobCategories.add( jobCategory( 5, "SmthElse", "lighten" ) );
        return jobCategories;
    }

    @Override
    public JobCategory getBy( Long jobId ) {
        JobCategory result;
        switch (jobId.intValue()) {
            case 1:
                result = jobCategory( 1, "Medicine", "pink");
                break;
            case 2:
                result = jobCategory( 2, "Rest", "purple");
                break;
            case 3:
                result = jobCategory( 3, "Peace", "greenLight" );
                break;
            case 4:
                result = jobCategory( 4, "CTO", "yellow" );
                break;
            case 5:
                result = jobCategory( 5, "SmthElse", "lighten" );
                break;
            default:
                result = jobCategory( 0, "Eat", "blue" );
                break;
        }
        return result;
    }

    private JobCategory jobCategory( Integer id, String name, String color ) {
        JobCategory jobCategory = new JobCategory();
        jobCategory.setId( id );
        jobCategory.setName( name );
        jobCategory.setColor( color );
        return jobCategory;
    }
}
